package com.rural.bus;

import org.json.JSONException;
import org.json.JSONObject;

import com.rural.bus.net.MyHttpUtil;
import com.rural.bus.net.OnNetCallback;
import com.rural.bus.net.Url;
import com.rural.bus.utils.ProgressUtil;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
/***
 * myaccount
 * @author fengyingyang
 *
 */
public class MyAccountActivity extends BaseActivity {
	
	private TextView mTvFee;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_myaccount);
		
		initView();
		setListeners();
		initData();
	}

	@Override
	protected void initView() {
		mBtMiddle.setText("我的账户");
		mBtMiddle.setVisibility(View.VISIBLE);
		mBtMiddle.setTextColor(getResources().getColor(R.color.white));

		mImgLeft.setVisibility(View.VISIBLE);
		mImgLeft.setBackgroundResource(R.drawable.back_bg_selector);
		
		mTvFee=(TextView) findViewById(R.id.tv_fee);
	}

	@Override
	protected void initData() {
		ProgressUtil.showProgress(this, "");
		MyHttpUtil http=new MyHttpUtil();
		http.addBodyParm("haveId", mCurrentUser.userId);
		http.addBodyParm("type", "0");
		http.send(Url.money_url, new OnNetCallback() {
			
			@Override
			public void success(JSONObject object) {
				ProgressUtil.closeProgress();
				Log.i("MyAccountActivity", object.toString());
				try {
					String result=object.getString("result");
					mTvFee.setText(result+" 元");
				} catch (JSONException e) {
					e.printStackTrace();
				}
			}
			
			@Override
			public void fail(String error) {
				ProgressUtil.closeProgress();
                toast(error);
			}
		});

	}

	@Override
	protected void setListeners() {
		mImgLeft.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
//				startActivity(MineActivity.class);
				finish();
			}
		});
	}

}
